package com.matt.controller.web.courseV2;

import com.matt.commons.model.StatusResponse;
import com.matt.domain.courseV2.MilepostUser;
import com.matt.domain.courseV2.po.CourseDetailsPO;
import com.matt.domain.courseV2.po.MilepostCardPO;
import com.matt.domain.courseV2.po.MilepostPO;
import com.matt.service.courseV2.MilepostService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

import static com.matt.foundation.constant.RequestConstant.TICKET;


@RestController
@RequestMapping("/api/milepost")
@Slf4j
@Api(tags = "教学 - 里程碑")
public class MilepostController {

    @Autowired
    private MilepostService milepostService;




    @ApiOperation(value = "里程碑列表")
    @PostMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "childrenId", value = "宝宝ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "timeAxis", value = "时间轴", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "name", value = "里程碑名称", required = false, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "states", value = "是否完成：0否，1是", required = false, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "completeStates", value = "完成状态：1按时完成，2提前完成，3超时完成", required = false, dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = MilepostPO.class),
    })
    public StatusResponse list(String childrenId,String timeAxis,String name,String states,String completeStates) {
        Map map = milepostService.list( childrenId, timeAxis,name, states, completeStates);
        return StatusResponse.success(map);
    }


    @ApiOperation(value = "添加")
    @PostMapping("/add")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "childrenId", value = "宝宝ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "milepostId", value = "标签ID", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "url", value = "附件", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = MilepostPO.class),
    })
    public StatusResponse add(String childrenId, String milepostId, String url ) {
        MilepostUser milepostUser = milepostService.add( childrenId, milepostId, url);
        return StatusResponse.success(milepostUser);
    }



    @ApiOperation(value = "里程碑小卡列表")
    @PostMapping("/cardList")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "classesId", value = "班级ID", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = MilepostPO.class),
    })
    public StatusResponse cardList(String classesId) {
        Map map = milepostService.cardList(classesId);
        return StatusResponse.success(map);
    }



    @ApiOperation(value = "里程碑小卡生成")
    @PostMapping("/addCard")
    public StatusResponse addCard(@RequestBody List<MilepostCardPO> milepostCard) {
        milepostService.addCard(milepostCard);
        return StatusResponse.success("成功");
    }



    @ApiOperation(value = "时间轴列表")
    @PostMapping("/timeAxis_list")
    public StatusResponse timeList() {
        List<Map> map = milepostService.timeAxis();
        return StatusResponse.success(map);
    }

}
